<!DOCTYPE html>
<html>
<head>
<title>req_assign</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

<link rel="stylesheet" type="text/css"
	href="/codebase/fonts/font_roboto/roboto.css" />
<link rel="stylesheet" type="text/css" href="/codebase/dhtmlx.css" />
<!-- <script type="text/javascript" src="/codebase/dhtmlx.js" /> -->
<script type="text/javascript" src="/codebase/dhtmlxform.js" />
<script type="text/javascript" src="/codebase/dhtmlxgrid.js" />
<style>
div#simpleLog {
	height: 200px;
	font-family: Roboto, Arial, Helvetica;
	font-size: 14px;
	color: #404040;
	overflow: auto;
}



</style>
<script>
	var myForm, my_form2,myGrid,formStructure1,formStructure2;
	
	function doOnLoad() {		
		
		//formStructure1=null;
		/*formStructure1=[
		                {type:"fieldset", name:"data", label:"单"}:[
		               {type:"input",name:"req_title",label:"主题关键字",inputWidth:"100",position:"label-left" },
		               {type:"newcolumn"},
		               {type:"input",name:"assign_btn2",label:"需求编号",inputWidth:"100", position:"label-left",offsetLeft:"50" }
			           ]    
		               ];
		*/
		if (myForm) {
			myForm.unload();
			myForm = null;

		}
		myForm=new dhtmlXForm("form_1");
		myForm.loadStruct("/common/testmanager/test_new_select_req_have_reqno_data.xml");
		
		
		
		
		myForm.attachEvent("onButtonClick", function(name) {		
			
			if(name=="req_query_btn"){
				
				var params = "?params=" + myForm.getItemValue("req_title")+"," + myForm.getItemValue("req_bill_no")+","+myForm.getItemValue("req_offer_dept")
				+ "," + myForm.getItemValue("deffect_no");
				//myGrid.clearAll();
				//myGrid.load("req/req_search" + params,callback_load,"json");
				myGrid.clearAndLoad("/test/req_search_for_test_input" + params,callback_load,"json");
			}
			}
		);
			
		
		//grid setup
		if (myGrid) {			
			myGrid.clearAll(true);			
		}
		myGrid = new dhtmlXGridObject("grid_req_list");
		//myGrid.loadStruct("/common/testmanager/req_list.xml");
		myGrid.setImagePath("/codebase/imgs/");

		myGrid.setHeader(",ID,需求编号,需求类型,需求主题,需求提出部门,缺陷号");
		myGrid.setInitWidths("50,50,150,100,250,150,150");
		myGrid.setColAlign("center,center,left,left,left,left,left");
		myGrid.setColTypes("ra,ed,ed,ed,ed,ed,ed");
		myGrid.setColSorting("str,str,str,str,str,str,str");
		//myGrid.setColumnIds("first,second");
		myGrid.xml.top = "mytop";
		myGrid.xml.row = "./myrow";
		//myGrid.enableAutoWidth(true);
		//myGrid.enableAutoHeight(true);
		myGrid.init();		
		//myGrid.load("/common/testmanager/req_list_test_data.xml", "xml");
		myGrid.attachEvent("onRowSelect",function(rowID,celInd){
		    //alert("The id of the selected row is "+rowID);		    
		    myGrid.cells(rowID,0).setValue("1");
		    
		});
		
		// button setup
		formStructure2=null;
		formStructure2=[					   
		               {type:"button",name:"next_btn",value:"下一步"}

			               ];
		
		if (my_form2) {
			my_form2.unload();
			my_form2 = null;
		}
		
		my_form2=new dhtmlXForm("form_btn");
		my_form2.loadStruct(formStructure2);
		
		my_form2.attachEvent("onButtonClick", function(name) {		
			
			if(name=="next_btn"){
				
				/* var get_row=myGrid.getCheckedRows(0);
				var get_req_id=myGrid.cells(get_row,1).getValue();				
				window.location.assign("/test/test_new_details?req_id="+get_req_id); */
				
				
				
				
				
				var get_row=myGrid.getCheckedRows(0);
				if(get_row==""){
					alert("请先选择一条需求");
				}
				else{	
					var get_row=myGrid.getCheckedRows(0);
					var get_req_id=myGrid.cells(get_row,1).getValue();
					parent.document.getElementById("select_req_id").innerHTML=get_req_id;
					parent.parent.dhxWins.window("select_req_window").close();					
				}
				
				//window.location.pathname="/test/test_new?req_id="+get_req_id;
				//my_form2.send("/test/test_new?req_id="+get_req_id);
				//parent.myLayout.cells("a").detachObject(true);		
				//parent.window.location.pathname="/test/test_new_details?req_id="+get_req_id;
				//parent.myLayout.cells("a").attachURL("/test/test_new_details?req_id="+get_req_id, true); 
				
			//	var id = "select_req_window";
			//	var obj=document.getElementById("select_req_id");
			//	obj.innerHTML=get_req_id;
				
						
				//document.getElementById("assign_req_id").innerHTML=get_req_id;
				//alert(" get_req_id "+get_req_id);
				//parent.dhxWins.window("select_req_window").close();
				
			}
		});		
	

	}	
	
	var callback_load = function() {
		//alert("查询完成");

// 		if (arguments[1] == "true") {
// 			alert("查询成功");
// 			myForm.reset();
// 		} else {
// 			alert("查询成功失败，错误信息：" + arguments[1]);
// 		}
	}

</script>
</head>
<body onload="doOnLoad();">
<div id="select_req_id" name="select_req_id" th:text="${req_id}" style="display: none;" > </div>
	<table>
		<tr>
			<td>
				<div id="form_1" ></div>
			</td>
		</tr>
	</table>		
	<table>
		<tr>
			<td>
			<div id="form_req_list" style="padding-left: 100px;"></div>
				<div id="grid_req_list"
					style="width: 800px; height: 200px; background-color: white;">
					</div>
			</td>
		</tr>
	</table>
	<table>
		<tr>
			<td>
				<div id="form_btn" style="padding-left: 50px;"></div>
			</td>
		</tr>
		
	</table>
</body>
</html>